package com.javaex.book.pojo;

import java.math.BigDecimal;

import com.javaex.book.utils.Constants;

public class Book {

	private Integer id;
	
	/** 书名 */
	private String name;
	
	/** 作者 */
	private String author;
	
	/** 价格 */
	private BigDecimal price;
	
	/** 销量 */
	private Integer sales;
	
	/** 库存 */
	private Integer stock;
	
	/** 封面图片 */
	private String imgPath;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		if (price.compareTo(Constants.BIGDECIMAL_ZERO) == -1) {
			price = Constants.BIGDECIMAL_ZERO;
		} 
		this.price = price;
	}

	public Integer getSales() {
		return sales;
	}

	public void setSales(Integer sales) {
		if (sales < 0) {
			sales = 0;
		}
		this.sales = sales;
	}

	public Integer getStock() {
		return stock;
	}

	public void setStock(Integer stock) {
		if (stock < 0) {
			stock = 0;
		}
		this.stock = stock;
	}

	public String getImgPath() {
		return imgPath;
	}
	
	public void setImgPath(String imgPath) {
		this.imgPath = imgPath;
	}

	@Override
	public String toString() {
		return "Book [id=" + id + ", name=" + name + ", author=" + author + ", price=" + price + ", sales=" + sales + ", stock=" + stock
				+ ", imgPath=" + imgPath + "]";
	}
	
}
